mui.init({
	swipeBack:false //右滑关闭功能
});
if(window.plus){
    plusReady();
}else{
    document.addEventListener('plusready',plusReady,true);
}
var selectxmbh
function plusReady(){
   var current=plus.webview.currentWebview();
   selectxmbh = current.selectxmbh;
   var xsxm=(selectxmbh.split("-")[1]);
   document.getElementById("xmbh").innerText=xsxm.trim();
   document.getElementById("jedw").innerText="元";
   getQueryData(selectxmbh);
   //返回首页
   document.getElementById('home').addEventListener('tap', function() {
	    var h=plus.webview.getWebviewById('mainpage');
	    plus.webview.show(h);
	    mui.fire(h,'tabClick',{tabId:'defaultTab'});
   });
}
function getQueryData(selectxmbh){
	var token = plus.storage.getItem("token");
	if(token==null||token==""){
		return;
	}else{
	   panUtil.ajaxLoding.start();
	   mui.ajax(baseServerAdrr+'/query/getlrfpcx',{
	   data: {
	   		token:token,
	   		xmbh:selectxmbh
	   },
	   dataType:'json',//服务器返回json格式数据
	   type:'post',//HTTP请求类型
	   timeout:30000,//超时时间设置为10秒；
	   success:function(data){
		    panUtil.ajaxLoding.stop();
		    if(data.code=='success'){
		    	initTable(data.message);
		    }else{
		    	mui.toast(data.message);
		    }
	   },
	   error:function(xhr,type,errorThrown){
		   //异常处理；
		   panUtil.ajaxLoding.stop();
		   mui.toast('服务器异常登录失败! query_hblrjlrfp.js');
	   }
	  });
	}
}
function initTable(data){
	
	var th="<tr><th width=\"30px\">序号</th><th width=\"50px\">月份</th><th width=\"80px\">本月数</th><th width=\"80px\">本年累计数</th>"+
	           "<th width=\"80px\">上年同期数</th></tr>";
	var table=th;
	for(var i=0;i<data.length;i++){
		var td="";
		if(i==0){
			td=td+"<tr class=\"pan_table_tr backcolor\">";
		}else{
			td=td+"<tr class=\"pan_table_tr\">";

		}
		td=td+"<td class=\"pan_table_xh\">"+(i+1)+"</td>";
		td=td+"<td class=\"pan_table_td_left\">"+data[i].bbzd_date+"</td>";

		var bylr=data[i].bylr;
		var bnlj=data[i].bnlj;
		var sntq=data[i].sntq;
		if(bylr<0){td=td+"<td class=\"pan_table_td_right\">-"+panUtil.fmoney(Math.abs(bylr),2)+"</td>";
		}else{td=td+"<td class=\"pan_table_td_right\">"+panUtil.fmoney(bylr,2)+"</td>";}
		if(bnlj<0){td=td+"<td class=\"pan_table_td_right\">-"+panUtil.fmoney(Math.abs(bnlj),2)+"</td>";
		}else{ td=td+"<td class=\"pan_table_td_right\">"+panUtil.fmoney(bnlj,2)+"</td>";	
		}if(sntq<0){
			td=td+"<td class=\"pan_table_td_right\">-"+panUtil.fmoney(Math.abs(sntq),2)+"</td>";
		}else{  td=td+"<td class=\"pan_table_td_right\">"+panUtil.fmoney(sntq,2)+"</td>";	}
		td=td+"</tr>";
		table=table+td;
	}	
	var tablediv=document.getElementById('pan_table');
	tablediv.innerHTML=table;
  
    mui("#pan_table_div").on('tap','.pan_table_tr',function(){
    	
    	$(this).addClass("backcolor").siblings("tr").removeClass("backcolor");
		$(this).siblings("tr").find("td").removeClass("backcolor_font");
	    $(this).find("td").addClass("backcolor_font");
    });    
}

